<template>
    <div>
        <div>
            <tabs :keyData="tabHead" :tableData="tableData"></tabs>
        </div>
        <div>

        </div>
    </div>

</template>
<script>
import { getOrderManage } from "@/api/orderManage"
import { MdseId } from "@/api/mdse"
import moment from 'moment'
export default {
    data() {
        return {
            tableData: [],
            tabHead: [
                { key: "complete", name: "订单状态" },
                { key: "mdseId", name: "商品信息" },
                // { key: "product", name: "商品信息" },
                { key: "mdseUpperLimit", name: "消费满" },
                { key: "mdseCashBack", name: "返现金额" },
                { key: "UserCarefulCheck", name: "审核人员" },
                { name: '订单图片', key: 'slot', slotName: "orderImage" },

                { key: "orderAmount", name: "订单金额" },
                { key: "comment", name: "订单评语" },
                { key: "evaluate", name: "拒绝原因" },
                { key: "orderNo", name: "拒绝原因" },
                { key: "remarks", name: "用户评论" },
                { key: "createdAt", name: "创建时间" },
                { key: "updatedAt", name: "修改时间" },
            ],
            pagination: {
                limit: 2,
                page: 1
            }

        }
    },
    mounted() {
        this.getOrderManage()
    },
    methods: {
        async getOrderManage() {
            try {
                let res = await getOrderManage(this.pagination);

                // 使用 Promise.all 等待所有异步操作完成
                let promises = res.list.map(async (item) => {
                    item.createdAt = moment(item.createdAt).format("YYYY-MM-DD HH:mm:ss");
                    item.updatedAt = moment(item.updatedAt).format("YYYY-MM-DD HH:mm:ss");
                    item.mdseCashBack = item.mdseCashBack / 100 + "元";

                    let mdse = await MdseId(item.mdseId);
                    item.mdseId = mdse.title;

                    return item;
                });

                // 等待所有 Promise 完成后再赋值给 this.tableData
                this.tableData = await Promise.all(promises);

                // 可以在这里进行其他操作，确保数据处理完成后再进行
                console.log(this.tableData);
            } catch (error) {
                console.error('获取订单管理数据失败：', error);
                // 可以在这里处理错误，例如显示错误提示等
            }
        }

    }
}
</script>
